<?php

declare(strict_types=1);
/**
 * This file is part of Sws.
 *
 * @link     https://gitee.com/sreeb/sws-dev.git
 * @document https://gitee.com/sreeb/sws-dev.git
 * @contact  https://gitee.com/sreeb/sws-dev.git
 * @license  https://gitee.com/sreeb/sws-dev/blob/master/LICENSE
 */
namespace app\event;

use sws\Event;
use sws\Server;

class SwsEvent
{
    /**
     * 框架初始化后事件（框架初始化了配置文件app设置，异常函数注册，日志目录）.
     */
    public function initialize()
    {
    }

    /**
     * swoole服务创建事件（此时已经注册了swoole的所有事件）.
     */
    public function serverCreate(Server $server)
    {
        //监听onRequest事件，并设置事件优先级（触发事件后会优先执行）
        Event::getInstance()->listen('onRequest', function (\Swoole\Http\Request $request, \Swoole\Http\Response $response) {
            //过滤图标请求
            if ($request->server['request_uri'] == '/favicon.ico') {
                return false;
            }
            return true;
        }, true);
    }
}
